package week7;
public class Person3 implements Cloneable {
    private String name;
    private int ID;
    Person3(String name, int ID){
        this.name = name;
        this.ID = ID;
    }
    public String getName() {
        return name;
    }
    public int getID() {
        return ID;
    }
    @Override
    protected Person3 clone() throws CloneNotSupportedException {
        return (Person3)super.clone();
    }

    public static void main(String[] args) {
        try {
            Person3 p = new Person3("Justin",20150001);
            Person3 p3 = p.clone();

            System.out.println(p);
            System.out.println(p3);
            System.out.println("p.getName().hashCode() : " + p.getName().hashCode());
            System.out.println("p3.getName().hashCode() : " + p3.getName().hashCode());
            String result = p.getName().hashCode() == p3.getName().hashCode() ? "浅拷贝" : "深拷贝";
            System.out.println(result);
        }catch(CloneNotSupportedException e){
            System.out.println(e);
        }
    }
}